$(document).ready(function () {
    initView()
});

function initView() {

   //初始化订单信息
    //获得id
    let id=getUrlString("id");

    let obj=new Object();
    obj.m="detail";
    obj.id=id;
    $.ajax({
        async:true,
        // Ajax请求设置xhrFields的withCredentials为true实现跨域访问
        xhrFields: {
            withCredentials: true
        },
        type:"POST",
        url:basePath2+"/api/auth/orders",
        dataType:"json",
        data:obj,
        success:function (result) {
            //console.log(result);
            if(result.code==200){
                initOrderInfo(result);
            }
        },
        error:function (e) {
            console.log(e.status);
            console.log(e.responseText);
        }
    });
    //初始化用户信息
    let member=new Object();
    member.m="getLoginMember";
    $.ajax({
        async:true,
        // Ajax请求设置xhrFields的withCredentials为true实现跨域访问
        xhrFields: {
            withCredentials: true
        },
        type:"POST",
        url:basePath2+"/api/member",
        dataType:"json",
        data:member,
        success:function (result) {
            //console.log(result);
            if(result.code==200){

                initUserInfo(result);
            }
        },
        error:function (e) {
            console.log(e.status);
            console.log(e.responseText);
        }
    });
    //初始化商品信息
    let merchant=new Object();
    merchant.m="merchantList";
    merchant.id=id;
    $.ajax({
        async:true,
        // Ajax请求设置xhrFields的withCredentials为true实现跨域访问
        xhrFields: {
            withCredentials: true
        },
        type:"POST",
        url:basePath2+"/api/auth/orders",
        dataType:"json",
        data:merchant,
        success:function (result) {
            //console.log(result);
            if(result.code==200){
                initMerchantInfo(result);
            }
        },
        error:function (e) {
            console.log(e.status);
            console.log(e.responseText);
        }
    });
}

/**
 * 初始化订单信息
 * @param result
 */
function initOrderInfo(result) {
    console.log("---初始化订单信息---")
    console.log(result);
}

/***
 * 初始化用户信息
 * @param result
 */
function initUserInfo(result) {
    console.log("---初始化用户信息---")
    console.log(result);
}

function initMerchantInfo(result) {
    console.log("---初始化购物车中商品信息---")
    console.log(result);
}